export const validmarkdwoncontenttypes = [
    "text/markdown",
    "text/plain",
    "text/css",
    "application/json",
];
export async function fetchinbrowser(u: string): Promise<string> {
    const r = await fetch(u);
    const contenttype = r.headers.get("content-type")?.split(";")[0];
    if (!r.ok) {
        throw new Error("fetch failed:" + "status:" + r.status + "\n" + u);
    } else if (
        !(contenttype && validmarkdwoncontenttypes.includes(contenttype))
    ) {
        throw new Error(
            "fetch failed:" +
                "content-type:" +
                r.headers.get("content-type") +
                "\n" +
                u
        );
    } else {
        return r.text();
    }
}
